package com.changgou.order.service.impl;

import com.changgou.order.dao.CollectMapper;
import com.changgou.order.pojo.Collect;
import com.changgou.order.service.CollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class CollectServiceImpl implements CollectService {

    @Autowired
    private CollectMapper collectMapper;



    @Override
    public List<Collect> list(String username) {
        Example example = new Example(Collect.class);
        Example.Criteria criteria = example.createCriteria();
        criteria.andEqualTo("username", username);
        List<Collect> collectList = collectMapper.selectByExample(example);
        if (collectList.size() <= 0 || collectList == null) {
            throw new RuntimeException("用户未收藏");
        }
        return collectList;
    }
}
